

package com.hazelcast.client.config;

/**
 * hazelcast.cloud configuration to let the client connect the cluster via hazelcast.cloud
 */
public class ClientCloudConfig {

    private String discoveryToken;
    private boolean enabled;

    public ClientCloudConfig() {
    }

    public ClientCloudConfig(ClientCloudConfig cloudConfig) {
        discoveryToken = cloudConfig.discoveryToken;
        enabled = cloudConfig.enabled;
    }

    /**
     * hazelcast.cloud discoveryToken of your cluster
     *
     * @return discoveryToken
     */
    public String getDiscoveryToken() {
        return discoveryToken;
    }

    /**
     * @param discoveryToken hazelcast.cloud discoveryToken of your cluster
     * @return configured {@link com.hazelcast.client.config.ClientCloudConfig} for chaining
     */
    public ClientCloudConfig setDiscoveryToken(String discoveryToken) {
        this.discoveryToken = discoveryToken;
        return this;
    }

    /**
     * @return true if enabled, false otherwise
     */
    public boolean isEnabled() {
        return enabled;
    }

    /**
     * @param enabled true to use hazelcast.cloud
     * @return configured {@link com.hazelcast.client.config.ClientCloudConfig} for chaining
     */
    public ClientCloudConfig setEnabled(boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        ClientCloudConfig that = (ClientCloudConfig) o;

        if (enabled != that.enabled) {
            return false;
        }
        return discoveryToken != null ? discoveryToken.equals(that.discoveryToken) : that.discoveryToken == null;
    }

    @Override
    public int hashCode() {
        int result = discoveryToken != null ? discoveryToken.hashCode() : 0;
        result = 31 * result + (enabled ? 1 : 0);
        return result;
    }

    @Override
    public String toString() {
        return "ClientCloudConfig{" + "enabled=" + enabled + '}';
    }
}
